package com.nanbei.eduService.controller;


import com.nanbei.commonUntil.R;
import com.nanbei.eduService.entity.vo.OneEduSubject;
import com.nanbei.eduService.service.EduSubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2021-12-28
 */
@RestController
@RequestMapping("/eduService/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService eduSubjectService;


    //添加课程分类
    //获取上传过来的文件,把文件内容读取出来
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){

        //获取上传过来的Excel文件
        eduSubjectService.saveSubject(file,eduSubjectService);

        return R.ok();
    }

    //课程分类列表管理   树形分类
    @GetMapping("findAllSubject")
    public R findAllSubject(){
        List<OneEduSubject> oneEduSubjectList = eduSubjectService.findOneTwoSubject();
        return R.ok().data("oneEduSubjectList",oneEduSubjectList);
    }
}

